package com.shop.serviceImpl.shop;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shop.entity.shop.Category;
import com.shop.entity.shop.CategorySecond;
import com.shop.entity.shop.Product;
import com.shop.mappers.shop.Product_mapper;
import com.shop.service.shop.Product_service;

@Service
public class Product_Service_Impl implements Product_service {

	@Autowired
	private Product_mapper ProductM;

	@Override
	public Category queayCategoryByCid(int cid) {
		return ProductM.queayCategoryByCid(cid);
	}

	@Override
	public CategorySecond queayCategorySecondByCsid(int csid) {
		return ProductM.queayCategorySecondByCsid(csid);
	}

	@Override
	public Product qreayProductByPname(String pname) {

		return ProductM.qreayProductByPname("%" + pname + "%");
	}

	@Override
	public List<Product> qreayProductByCsid(int csid) {

		return ProductM.qreayProductByCsid(csid);
	}

	@Override
	public List<Category> queayCategorys() {
		List<Category> categorys = ProductM.queayCategorys();
		for (Category category : categorys) {
			category.setCategorySecondList(ProductM.queayCategorySecondByCid(category.getCid()));
		}
		return categorys;
	}

	@Override
	public List<Product> qreayProducts() {
		return ProductM.qreayProducts();
	}

	@Override
	public List<CategorySecond> queayCategorySecondByCid(int cid) {
		return ProductM.queayCategorySecondByCid(cid);
	}

}
